// // Copyright (c) 2009 All Right Reserved // // vl // // 2009-01-01 // Contains ... using System.Diagnostics.Contracts; using System.Globalization; using System.Text; using System.Xml.Linq; using JetBrains.Annotations; using LargoCommon.Localization; namespace LargoCommon.Music { /// /// Octave Change. /// public sealed class OctaveChange : AbstractChange { #region Constructors /// /// Initializes a new instance of the class. /// [UsedImplicitly] public OctaveChange() { } /// /// Initializes a new instance of the class. /// /// The given change. public OctaveChange(XElement xchange) : base(xchange) { Contract.Requires(xchange != null); //// if (xchange == null) { return; } this.MusicalOctave = DataEnums.ReadAttributeMusicalOctave(xchange.Attribute("MusicalOctave")); this.MusicalBand = DataEnums.ReadAttributeMusicalBandType(xchange.Attribute("MusicalBand")); ////201509!!!!! this.MusicalOctave = (MusicalOctave)LibSupport.ReadByteAttribute(xchange.Attribute("MusicalOctave")); //// this.MusicalOctave = LargoBase.Enums.MusicalOctave.OneLine; ////201509!!!!! this.MusicalBand = (MusicalBand)LibSupport.ReadByteAttribute(xchange.Attribute("MusicalBand")); //// this.MusicalBand = LargoBase.Enums.MusicalBand.MiddleTones; this.ChangeType = MusicalChangeType.Octave; } /// /// Initializes a new instance of the class. /// /// The given bar. /// The given line. public OctaveChange(int givenBar, int givenLine) : base(givenBar, givenLine, MusicalChangeType.Octave) { } /// /// Initializes a new instance of the class. /// /// The given bar. /// The given line. /// The given octave. public OctaveChange(int givenBar, int givenLine, MusicalOctave givenOctave) : base(givenBar, givenLine, MusicalChangeType.Octave) { this.MusicalOctave = givenOctave; this.MusicalBand = MusicalProperties.BandTypeFromOctave(givenOctave); } #endregion #region Properties - Xml /// /// Gets Xml representation. /// /// /// Property description. /// public override XElement GetXElement { get { var change = base.GetXElement; change.Add(new XAttribute("MusicalOctave", this.MusicalOctave)); change.Add(new XAttribute("MusicalBand", this.MusicalBand)); return change; } } #endregion #region Properties /// Gets or sets class of melodic part. /// Property description. public MusicalOctave MusicalOctave { get; set; } /// Gets or sets class of melodic part. /// Property description. public MusicalBand MusicalBand { get; set; } /// /// Gets BandTypeString. /// /// Property description. //// Do not make private!!! - It is used by DetailMusicalChanges.xaml. [UsedImplicitly] public string OctaveString => LocalizedMusic.String("Octave" + ((int)this.MusicalOctave).ToString(CultureInfo.CurrentCulture)); /// /// Gets BandTypeString. /// /// Property description. //// Do not make private!!! - It is used by DetailMusicalChanges.xaml. [UsedImplicitly] public string BandTypeString => LocalizedMusic.String("Band" + ((int)this.MusicalBand).ToString(CultureInfo.CurrentCulture)); #endregion #region Public methods /// /// Clones this instance. /// /// Returns object. public override object Clone() { var tmc = new OctaveChange(this.BarNumber, this.LineIndex) { MusicalOctave = this.MusicalOctave, MusicalBand = this.MusicalBand }; //// tmc.BlockModel = this.BlockModel; return tmc; } #endregion #region String representation /// String representation of the object. /// Returns value. public override string ToString() { var s = new StringBuilder(); s.AppendFormat(CultureInfo.CurrentCulture, base.ToString()); s.Append("," + this.OctaveString); s.Append("," + this.BandTypeString); return s.ToString(); } #endregion } }